package GUI;

import javax.xml.stream.events.StartDocument;

import Control.Episode;

class EpisodeButton extends Component
{
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
	public EpisodeButton(Episode e)
	{
		width =  165;
		height = 25;
		this.e = e;
		label = new String (e.getNumEpisode()+"- "+this.e.getName());
	}
	public void draw()
	{
		Utils.globalProcessing.textFont(Utils.plotFont, 13);
		if(label.length()>Utils.MAX_EPISODE_LENGTH)
			width = 185;
		else width = (int)(Utils.globalProcessing.textWidth(label)) + 10;
		int cx = x;
		int cy = y;
		if(label != null)
		{
			Utils.globalProcessing.textAlign(Utils.globalProcessing.LEFT);

			if(mouseOver()) 
			{
				super.draw();
				if(Utils.globalProcessing.mousePressed)
				{

					Utils.gu.drawVGradient(x, y + height, width, -height, Utils.globalProcessing.color(150, 150, 180), 80, Utils.globalProcessing.color(150, 150, 180), 255, (float)0.8);    
					Utils.gu.drawBox(x, y, width, height, 0, Utils.globalProcessing.color(150, 150, 200), 255);
					Utils.gu.drawBox(x, y, width, height, 1, Utils.globalProcessing.color(150, 150, 200), 150);
					cx += 2;
					cy += 2;

					
					
					Utils.startEpisodeSelected = e;
					Utils.endEpisodeSelected = e;
					Utils.hs.modifySliders(e);
					Utils.graphArea.seasonEpisodeButton.state =true;
					Utils.graphArea.createLineGraphPoints();
					Utils.graphArea.seasonEpisodeButton.label=Utils.graphArea.seasonEpisodeButton.label1;
					
					
				}
					
					if(label.length()>Utils.MAX_EPISODE_LENGTH){
						Utils.episodeHighLight = this;
					}
					
				
			}
			else if(Utils.episodeHighLight == this)
						Utils.episodeHighLight = null;


			Utils.globalProcessing.strokeWeight(1);
			Utils.globalProcessing.fill(255);
			Utils.globalProcessing.textFont(Utils.plotFont, 13);
			if(label.length()>Utils.MAX_EPISODE_LENGTH)
				Utils.globalProcessing.text(label.substring(0, Utils.MAX_EPISODE_LENGTH)+"...", cx + 5, cy + 15);
			else
				Utils.globalProcessing.text(label, cx + 5, cy + 15);

		}
	}

	
	public void drawInfoBox(int x,int y,int width, String label){
	    Utils.globalProcessing.fill(200);
	    Utils.globalProcessing.stroke(80);
	    Utils.globalProcessing.strokeWeight(1);
	    Utils.globalProcessing.rect(x, y, width, 30);

	    Utils.globalProcessing.fill(0);
	    //Utils.globalProcessing.textFont(Utils.globalProcessing.plotFont, 14);
	    Utils.globalProcessing.textAlign(Utils.globalProcessing.LEFT);
	    Utils.globalProcessing.text(label, x + 5, y + 20);
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
	String label;
	Episode e;
}